function readccc(filename)

if nargin>0
    if(exist(filename,'file'))
        [pathname filename ext] = fileparts(filename);
        filelist = {[filename ext]};
    end
else
    [filelist pathname] = jcb_pick_files('*.ccc','pick a ccc file to plot',false);
end

f=fopen(fullfile(pathname,filelist{1}));

figure(clf);
axis equal
xlabel('X/\mum');
ylabel('Y/\mum');
shapes=cell(0);
extremes = Inf*[1 1; -1 -1];

while ~feof(f)
    textline=fgetl(f);
    if regexp(textline,'/\* CZ')>0
        n = regexp(textline,'/\* CZ(?<fieldsize>[\d\.]*),(?<dots>\d*)','names');
        fieldsize = str2double(n.fieldsize)*1000;
        dots=str2double(n.dots);
        scalefactor=fieldsize/dots;
    elseif ~isempty(strfind(textline,'DWTZL(')) || ~isempty(strfind(textline,'DWSL('))
        c = regexp(textline,'[,\(]((-?\d*(\.\d)?))*','tokens');
        shape=struct('x',zeros(length(c)/2-1,1),...
                     'y',zeros(length(c)/2-1,1));
        for ii=0:length(c)/2-2
            shape.x(ii+1)=str2double(c{2*ii+1}{1});
            shape.y(ii+1)=str2double(c{2*ii+2}{1});
        end
        shape.x=scalefactor*shape.x;
        shape.y=scalefactor*shape.y;
        
        if ~isempty(strfind(textline,'DWSL('))
            shape.x = shape.x([1 2 2 1]);
            shape.y = shape.y([1 1 2 2]);
        end
        
        extremes(1,:)=min(extremes(1,:),[min(shape.x) min(shape.y)]);
        extremes(2,:)=max(extremes(2,:),[max(shape.x) max(shape.y)]);
        shapes{end+1}=shape;
        p=patch(shape.x,shape.y,0.8*[1 1 1]);
    end
end
fclose(f);

minvals=extremes(1,:);
maxvals=extremes(2,:);
field.x = minvals(1)+[0 0 1 1 0]*fieldsize;
field.y = maxvals(2)-[0 1 1 0 0]*fieldsize;
line( field.x,field.y,'color','r');
xlim(minvals(1)+fieldsize*[-0.1 1.1]);
ylim(maxvals(2)+fieldsize*[-1.1 0.1]);

line(fieldsize*[0 0 1 1 0],fieldsize*[0 1 1 0 0],'color','r');
xlim(fieldsize*[-0.1 1.1]);
ylim(fieldsize*[-0.1 1.1]);